<?php

namespace App\Admin\Controllers;

use App\Models\SuningApiLog;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;

class SuningApiLogErrorController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = 'SuningApiLog';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new SuningApiLog());

        $grid->model()->orderBy('updated_at', 'desc');

        $grid->column('id', __('Id'));
        $grid->column('from', __('From'));
        $grid->column('req_url', __('Req url'));
        $grid->column('req_method', __('Req method'));
        $grid->column('req_param', __('Req param'));
        // $grid->column('req_body', __('Req body'));
        $grid->column('resp_status', __('Resp status'));
        // $grid->column('resp_body', __('Resp body'));
        $grid->column('created_at', __('Created at'));
        $grid->column('updated_at', __('Updated at'));

        return $grid;
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     * @return Show
     */
    protected function detail($id)
    {
        $show = new Show(SuningApiLog::findOrFail($id));

        $show->field('id', __('Id'));
        $show->field('from', __('From'));
        $show->field('req_url', __('Req url'));
        $show->field('req_method', __('Req method'));
        $show->field('req_param', __('Req param'));
        $show->field('req_body', __('Req body'));
        $show->field('resp_status', __('Resp status'));
        $show->field('resp_body', __('Resp body'));
        $show->field('created_at', __('Created at'));
        $show->field('updated_at', __('Updated at'));

        return $show;
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new SuningApiLog());

        $form->text('from', __('From'));
        $form->text('req_url', __('Req url'));
        $form->text('req_method', __('Req method'));
        $form->text('req_param', __('Req param'));
        $form->textarea('req_body', __('Req body'));
        $form->number('resp_status', __('Resp status'));
        $form->textarea('resp_body', __('Resp body'));

        return $form;
    }
}
